package com.fierce.cloud.ota.controller;

import com.fierce.cloud.core.web.ResultGenerator;
import com.fierce.cloud.core.web.responseDto.Response;
import com.fierce.cloud.security.common.contants.SecurityConstants;
import com.fierce.cloud.security.common.utils.CurrentUserUtils;
import com.fierce.cloud.security.common.utils.JwtTokenUtils;
import com.fierce.cloud.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Optional;

/**
 * @author: Fierce
 * @Date: 2021/2/6 16:52
 */
public class TestController {

    @Autowired
    RedisUtil redisUtil;

    @Autowired
    private CurrentUserUtils currentUserUtils;

    @PostMapping("/")
    @PreAuthorize("hasRole('ADMIN')")
    public Response test(HttpServletRequest httpServletRequest) {
        return ResultGenerator.genSuccessResult(currentUserUtils.getCurrentUser());
    }
}
